package com.yd.sdk.analysisimp;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Gravity;
import android.widget.FrameLayout;


import com.google.firebase.analytics.FirebaseAnalytics;

import com.yd.sdk.analysis.AnalysisAbstractClass;

public class AnalysisImp extends AnalysisAbstractClass {

    private static final String TAG  = "AnalysisImp";
    private FirebaseAnalytics _analytics;
    private static Handler handler;
    @Override
    public void Initialize(String key) {

    }

    @Override
    public void LogEvent(String name,String key, String message) {
        Log.e(TAG,name +"," + key +"," + message);
//        throw new RuntimeException("Test Crash");
        handler.post(new Runnable() {
            @Override
            public void run() {
                if(_analytics != null)
                {
                    Bundle bundle = new Bundle();
                    bundle.putString(key,message);
                    if(_analytics == null)
                    {
                        Log.e(TAG,"_analytics = null");
                    }else
                    {
                        _analytics.logEvent(name,bundle);
                        Log.e(TAG,name +"," + key +"," + message);
                    }

                }else
                    Log.e(TAG,"FirebaseAnalytics is null");
            }
        });

    }

    @Override
    public void onCreate(Activity activity, Bundle savedInstanceState) {
        this.activity = activity;
        id = "Firebase-Analysis";
        handler = new Handler();
        _analytics = FirebaseAnalytics.getInstance(activity);
    }

    @Override
    public void onPause() {

    }

    @Override
    public void onResume() {

    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantRes) {

    }

}
